package com.comm.dao.imp;

import com.alibaba.fastjson.JSON;
import com.comm.entity.ExpressCompanyMapping;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import java.util.List;
import java.util.Map;

/***
 * @DESCRIPTION: 物流关系映射
 * @author 枫伦
 * @params:
 * @return:
 * @Date: 2021/7/20 5:04 下午 
 * @Modified By:  
 */
public class ExpressCompanyMappingDao extends SqlMapClientDaoSupport {

    /**
     * 支持重复主键触发更新的操作
     */
    public void insert(ExpressCompanyMapping expressCompanyMapping) {
        Object object = getSqlMapClientTemplate().insert("ExpressCompanyMapping.insert", expressCompanyMapping);
        System.out.println(JSON.toJSONString(object));
//        expressCompanyMapping.setId(id);
    }

    public int logicDeleteById(Long id) {
        if (id == null) {
            return 0;
        }
        return getSqlMapClientTemplate().update("ExpressCompanyMapping.logicDeleteById", id);
    }

    public int batchUpdate(List<ExpressCompanyMapping> expressCompanyMappings) {
        if (expressCompanyMappings == null || expressCompanyMappings.size() == 0) {
            return 0;
        }
        return getSqlMapClientTemplate().update("ExpressCompanyMapping.batchUpdate", expressCompanyMappings);
    }

    public int update(ExpressCompanyMapping expressCompanyMapping) {
        return getSqlMapClientTemplate().update("ExpressCompanyMapping.update", expressCompanyMapping);
    }

    public List<ExpressCompanyMapping> getExpressCompanyMappingByExample(Map<String, Object> params) {
        return getSqlMapClientTemplate().queryForList("ExpressCompanyMapping.selectByExample", params);
    }

    public int batchInsert(List<ExpressCompanyMapping> expressCompanyMappings) {
        for (ExpressCompanyMapping expressCompanyMapping : expressCompanyMappings) {
            Object insert = getSqlMapClientTemplate().insert("ExpressCompanyMapping.insert", expressCompanyMapping);
            System.out.println(JSON.toJSONString(insert));

        }
        return expressCompanyMappings.size();
    }
}
